using System.Linq;
using ResxHelper.Object;

namespace ResxHelper.Logic.Formatters
{
    public class ResourceFileCsvFormatter : IResourceFileFormatter
    {
        public ResourceFile InputFile { get; private set; }

        public ResourceFileCsvFormatter(ResourceFile input)
        {
            InputFile = input;
        }

        public string Run()
        {
            return InputFile.Entries.Aggregate(string.Empty, (current, item) =>
                                                             current + string.Format("{0},{1},{2}\n", item.Key, item.Value.Value, item.Value.Comment));
        }
    }
}